<template>
  <BasisTable
    v-model:page="Page"
    v-model:sortOptions="sortOptions"
    v-model:selectOptions="selectOptions"
    :list="DataList"
    :amount="Amount"
    :columns="getcolumns"
    @rowClick="handleRowClick"
  >
  </BasisTable>
</template>
<script setup>
import { ref, computed, watch } from 'vue'
import { BasisTable } from '@/components'

const options = ref({
  page: '1',
  typeId: '',
  departmentId: '',
  handlingStatus: '',
  time: '',
})

const DataList = ref([
  {
    pkid: 270,
    title: '阿萨大阿萨大',
    typeTitle: '其他诉求',
    name: '王江超',
    tel: '17194377734',
    department: '企业服务中心',
    time: '2022/7/21 9:34:30',
    state: 0,
    isRead: true,
  },
  {
    pkid: 221,
    title: '12',
    typeTitle: '资产税务',
    name: '王江超',
    tel: '17194377734',
    department: '财政局',
    time: '2022/7/5 16:34:44',
    state: 0,
    isRead: true,
  },
  {
    pkid: 220,
    title: '12312312',
    typeTitle: '投资融资',
    name: '王江超',
    tel: '17194377734',
    department: '长沙融城发展集团有限公司、文化广告产业园、人力资源产业园',
    time: '2022/7/5 16:32:25',
    state: 0,
    isRead: true,
  },
  {
    pkid: 219,
    title: 'asd',
    typeTitle: '政策信息',
    name: '王江超',
    tel: '17194377734',
    department: '长沙融城发展集团有限公司、文化广告产业园、人力资源产业园',
    time: '2022/7/5 16:32:14',
    state: 0,
    isRead: true,
  },
])
const Amount = ref(0)
const Page = computed({
  get: () => options.value.page,
  set: (val) => {
    options.value = {
      ...options.value,
      page: val,
    }
  },
})
const sortOptions = computed({
  get: () => {
    return {
      time: options.value.time,
    }
  },
  set: (val) => {
    const { time } = val
    options.value = {
      ...options.value,
      time: time,
      page: '1',
    }
  },
})
let selectOptions = computed({
  get: () => {
    return {
      department: options.value.departmentId,
      state: options.value.handlingStatus,
      typeTitle: options.value.typeId,
    }
  },
  set: (val) => {
    const { department, state, typeTitle } = val
    options.value = {
      ...options.value,
      departmentId: department,
      handlingStatus: state,
      typeId: typeTitle,
      page: '1',
    }
  },
})

let getcolumns = computed(() => [
  {
    dataIndex: 'order',
    title: '序号',
    tdslot: true,
    width: '6',
  },
  {
    dataIndex: 'title',
    title: '诉求名称',
    tdslot: true,
    omit: true,
    width: '35',
  },
  {
    dataIndex: 'typeTitle',
    title: '诉求类型',
    width: '13',
    selectable: true,
    options: [{ value: '', name: '全部' }],
  },
  {
    dataIndex: 'name',
    title: '诉求提报人',
    width: '13',
  },
  {
    dataIndex: 'tel',
    title: '联系电话',
    width: '13',
  },
  {
    dataIndex: 'department',
    title: '办理部门',
    omit: true,
    align: 'left',
    selectable: true,
    options: [{ value: '', name: '全部' }],
    width: '15',
  },
  {
    dataIndex: 'time',
    title: '诉求提报时间',
    sortable: true,
    width: '16',
  },
  {
    dataIndex: 'state',
    title: '办理状态',
    tdslot: true,
    selectable: true,
    options: [
      { value: '', name: '全部' },
      { value: '0', name: '待分发' },
      { value: '1', name: '办理中' },
      { value: '2', name: '已办理' },
      { value: '3', name: '已办结' },
    ],
    width: '12',
  },
])

watch(
  () => options.value,
  () => {
    DataList.value = [
      {
        pkid: 218,
        title: 'asd',
        typeTitle: '项目申报',
        name: '王江超',
        tel: '17194377734',
        department: '行政审批局',
        time: '2022/7/5 16:31:25',
        state: 0,
        isRead: true,
      },
      {
        pkid: 217,
        title: 'asd',
        typeTitle: '资产税务',
        name: '王江超',
        tel: '17194377734',
        department: '财政局',
        time: '2022/7/5 16:29:00',
        state: 0,
        isRead: true,
      },
      {
        pkid: 216,
        title: 'as',
        typeTitle: '资产税务',
        name: '王江超',
        tel: '17194377734',
        department: '财政局',
        time: '2022/7/5 16:28:00',
        state: 0,
        isRead: true,
      },
      {
        pkid: 208,
        title: 'wjc003',
        typeTitle: '资产税务',
        name: '王江超',
        tel: '17194377734',
        department: '',
        time: '2022/7/4 15:08:00',
        state: 0,
        isRead: true,
      },
      {
        pkid: 204,
        title: 'wjc001',
        typeTitle: '资产税务',
        name: '王江超',
        tel: '17194377734',
        department: '文化广告产业园',
        time: '2022/7/4 10:59:58',
        state: 0,
        isRead: true,
      },
    ]
  }
)

const handleRowClick = () => {}
</script>
